package com.mimosa.common.system.dic;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

@Aspect
public class DicOpAspect {
	final Logger logger = LoggerFactory.getLogger(DicOpAspect.class);
	@Autowired
	private ExtractService extractService;

	/** 删除用户 ***/
	@AfterReturning(value = "execution(* com.touchwisdom.modular.common.system.dic.DicSettingEntityService.saveEntity(..))&&args(entity)")
	public void insertDicValue(TDicSettingEntity entity) {
		logger.info("新增字典信息 : " + entity.getDicName());
		this.extractService.initializeExtractor(entity.getClassType());
	}

	/**
	 * 添加用户
	 * 
	 * @param user
	 */
	@Before(value = "execution(* com.touchwisdom.modular.common.system.dic.DicSettingEntityService.deleteEntityList(..))")
	public void regiestLog_createUser() {
		logger.info("重新初始化日志信息: ");
		this.extractService.initializeExtractor();
	}
}